%%inits 
addpath '../gmm';
addpath '../common';
addpath '../ngplus';
addpath '/Users/pteufl/Desktop/PHD/matlab/PHD/RGNGreal/';

%load global definitions from gmm
globals;

%create parameters and random gauss dist
%[priors,mmus,rr] = gmmparams(2,10,0.1);         % dim 2 and 10 distributions
%[D,labels] = gmmrnd(priors,mmus,rr,1000);   % 1000 data points
load all;
f=figure(1);

%% ng training
%apply gng algorithm
neuralGasMap = gng(D);
traceData=neuralGasMap.traceData;
mdlValues=[];

for i=1:length(traceData)
   neuralGasMap = traceData{i};
   gmmplot(neuralGasMap,mmus,rr,0,f);
   mdlValues=[mdlValues neuralGasMap.mdl];
   %mdl1 = MDL(neuralGasMap);
   %mdl2 = outliertest([neuralGasMap.D zeros(size(neuralGasMap.D,1),1)], neuralGasMap.M);
   %mdlvalues1=[mdlvalues1 mdl1];
   %mdlvalues2=[mdlvalues2 mdl2];
end
%pause;
%remove links
%distance
%analyze link matrix
%[linkDensities,linkStrength,linkDistances] = analyzeLinkMatrix(neuralGasMap);
%neuralGasMap = removeLinks(neuralGasMap,linkDistances,0.25);
%gmmplot(neuralGasMap,mmus,rr,0,f);
%pause

%strength
%analyze link matrix
%[linkDensities,linkStrength,linkDistances] = analyzeLinkMatrix(neuralGasMap);
%neuralGasMap = removeLinks(neuralGasMap,linkStrength,0.2);
%gmmplot(neuralGasMap,mmus,rr,0,f);
%pause

%density
%analyze link matrix
%[linkDensities,linkStrength,linkDistances] = analyzeLinkMatrix(neuralGasMap);
%neuralGasMap = removeLinks(neuralGasMap,linkDensities,0.2);
%gmmplot(neuralGasMap,mmus,rr,0,f);

%% mdl converter
mdlvaluesNew=[];
counter=1;
for i=1:(length(mdlValues)/2);
    mdlvaluesNew(i) = mdlValues(counter+1)-mdlValues(counter);
    counter=counter+2;
end;
figure(2)
plot(mdlValues,'b');
    
    
